//
//  LoginApi.m
//  YJ
//
//  Created by 吴志勇 on 2020/4/2.
//  Copyright © 2020 wzy. All rights reserved.
//

#import "LoginApi.h"

@implementation LoginApi
{
    NSString *_url;
    NSDictionary *_argument;

}

- (NSDictionary<NSString *,NSString *> *)requestHeaderFieldValueDictionary{
    NSMutableDictionary *newDict = [NSMutableDictionary dictionary];
    NSString *token = [[NSUserDefaults standardUserDefaults] stringForKey:@"token"] ;
    NSString *BearerToken = [NSString stringWithFormat:@"Bearer %@",token];
//    NSLog(@"%@",);
    [newDict setValue:BearerToken forKey:@"Authorization"];
    return newDict;
}

- (id)initWithUrl:(NSString *)url requestArgument:(NSDictionary *)argument{
    self = [super init];
    if (self) {
        _url = url;
        _argument = argument;
    }
    return self;
}


- (NSString *)requestUrl {
    
    return _url;
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (id)requestArgument {
//    NSLog(@"%@",_argument);
    return _argument;
}

- (void)startWithCompletionBlockWithSuccess:(nullable HXRequestCompletionBlock)success
                                    failure:(nullable HXRequestCompletionFailureBlock)failure{
    [super startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        
        NSDictionary *result = [request responseJSONObject];
        
        BOOL isSuccess = YES;
        
        //校验格式
  
        
        success(request,result,isSuccess);
        
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
//
//        NSLog(@"%@",self.description);
        
//        failure(request,self.errorInfo);
    }];
    
  
}



@end
